
#import "ArticleHeaderController.h"
#import "../Alexandra.h"
#import "../MainWindowControl.h"
#import "../ArticleViewControl.h"

@implementation ArticleHeaderController

- init
{
	[super init];
	if([NXApp loadNibSection:"ArticleInspector.nib" owner:self withNames:NO]==nil)
		EM_ERROR(EGENFileNotFound,"ArticleInspector.nib",NULL);

	return self;
}

- windowDidUpdate:sender
{
	id newWindow=[NXApp mainWindow];
	id newArticle=nil;
	id aDelegate=nil;
	
	if(newWindow && (aDelegate=[newWindow delegate],aDelegate))
		if([aDelegate isKindOf:[MainWindowControl class]])
			newArticle=[[aDelegate articleSet] currentSelection];
	
	if(newArticle!=currentArticle)
		if(newArticle)
			[theText setText:[[aDelegate articleViewControll] articleHeader]];
		else
			[theText setText:""];
			
	currentArticle=newArticle;		
	return self;
}

- window
{
	return window;
}

@end
